ajax("get","header.html").then(result=>{
    // var header=document.getElementById("header");
    console.log(typeof result)
   
    document.getElementById("header").innerHTML=result;
    var head=document.getElementsByTagName("head")[0]
    head.innerHTML+=`<link rel="stylesheet" href="css/header.css">`
   
//     var header=document.createElement("header");
//     var div=document.getElementsByClassName("container")[0]
//     document.body.insertBefore(header,div)
//    header.innerHTML=result;
    
    // console.log(head)
    // console.log(header)
    // console.log(result)
    // var head=document.getElementsByTagName("head")[0]
    // console.log(head)
    // head.appendChild(`<link rel="stylesheet" href="css/header.css">`)
//     var header=`result`
 
   
//   var head=document.getElementsByTagName("head")[0];
//         head.appendChild(`<link rel="stylesheet" href="css/header.css">`)
  
//    console.log(header)
   
})
// 给右侧导航栏加底部动画
var bottom=document.getElementById("bottom1")
console.log(bottom)
bottom.onclick=function(){
    length=document.documentElement.scrollTop||document.body.scrollTop
    var steps=50;
    var dur=500;
    var step=length/steps;
    var interval=dur/steps
    var timer=setInterval(()=>{
            window.scrollBy(0,-step)
            steps--;
            if(steps==0){
                clearInterval(timer);
                steps=50
            }
    },interval)
}
//获取元素
var picture=document.getElementById("picture")
console.log(picture)
//获取元素位置
var length1=picture.offsetTop
console.log(`${length1}图片距离`)

// 滚动触发事件
window.onscroll=function(){
    length=document.documentElement.scrollTop||document.body.scrollTop;
    console.log(length)
  //滚动到700-900添加动画
    if(length>700&&length<900){

        picture.classList.add('animate__animated', 'animate__heartBeat');
        console.log("加了动画")
       
    }
}
// 单击刚刚地图坐标
var card1=document.querySelector("#p1>div:nth-child(1)>div>a")
console.log(card1)
card1.onclick=function(){
    console.log("更换坐标")
    var map = new BMap.Map("baidumap");
    // 创建地图实例
    var point = new BMap.Point(114.123471,22.536031);
    // 创建点坐标
    map.centerAndZoom(point,20);
    // 初始化地图，设置中心点坐标和地图级别
    map.enableScrollWheelZoom(true); 
    var marker = new BMap.Marker(point);
    map.addOverlay(marker);
}
